const Mock = require('mockjs')

const data = Mock.mock({
  'items|30': [{
    id: '@id',
    title: '@sentence(10, 20)',
    'status|1': ['published', 'draft', 'deleted'],
    author: 'name',
    display_time: '@datetime',
    pageviews: '@integer(300, 5000)'
  }]
})
// --------------返回数据---------------
const Data = Mock.mock({
  'items|100': [{
    id: '@id',
    "array|1": [
      "JP",
      "US",
      "EU",
      "CN",
      "JP",
    ], //-------------操作类型
    name: '@cname',   //-----------------------操作人

    title: '@cparagraph(1, 3)', //----------------执行结果
    timer: '@datetime', // --------------时间
    "number|10-99.2": 1,
  }]
})

module.exports = [
  {
    url: '/vue-admin-template/table/list',
    type: 'get',
    response: config => {
      const items = data.items
      return {
        code: 20000,
        data: {
          total: items.length,
          items: items
        }
      }
    }
  },
  {
    url: '/vue-admin-template/table',
    type: 'get',
    response: config => {
      console.log(config); //---------请求的数据
      const { pagesize } = config.body
      return {
        success: false,
        message: '成功',
        total: 100,
        Data: Mock.mock({
          ['items|' + pagesize]: [{
            id: '@id',
            "array|1": [
              "JP",
              "US",
              "EU",
              "CN",
              "JP",
            ], //-------------操作类型
            name: '@cname',   //-----------------------操作人

            title: '@cparagraph(1, 3)', //----------------执行结果
            timer: '@datetime', // --------------时间
            "number|10-99.2": 1,
          }]
        })
      }
    }
  }
]
